package bsp.diff;

import java.io.IOException;

import org.apache.commons.functor.UnaryFunction;
import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.io.Writable;
import org.apache.hama.bsp.BSPPeer;
import org.apache.hama.bsp.sync.SyncException;

import util.DiffComputation;
import util.Parsable;
import util.functors.AccociBinaryOP;
import util.functors.BinaryOperator;
import bsp.CMapper;

public class DiffMapper<T0 extends Parsable<T0>, T1 extends Parsable<T1>, T2 extends Parsable<T2>
, M extends Writable>
extends CMapper<LongWritable, Text, Text, NullWritable, Text> {

	protected long chunkey;
	protected T1 cons_c;
	protected DiffComputation<T0, T1, T2> diff;
	protected UnaryFunction<T1, T2> g;
	protected AccociBinaryOP<T2> oplus;
	protected AccociBinaryOP<T1> otimes;
	protected T1 otimsAcc;
	protected T1 otimsAccPrew;
	protected BinaryOperator<T0, T1, T2> p;
	protected UnaryFunction<T0, T1> q;
	
	public DiffMapper(DiffComputation<T0, T1, T2> di) {
		this.diff = di;
		this.oplus = diff.oplus;
		this.otimes = diff.otimes;
		this.g = diff.g;
		this.p = diff.p;
		this.q = diff.q;
		this.cons_c = diff.init;
		
//		flg = 0;
//		chunkey = -1;
		otimsAcc = otimes.id();
		otimsAccPrew = otimes.id();
	}
	
//	public void transferStates(
//			DiffMapper<T0, T1, T2> other )
//			throws IOException, SyncException, InterruptedException{
//		
//	}
	
	@Override
	public void map(
			BSPPeer<LongWritable, Text, Text, NullWritable, Text> peer)
			throws IOException, SyncException, InterruptedException{
		
	}

}
